home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pesquisa Dirigida
/
Pesquisa Dirigida.iso
/
JOGOS
/
parking.swf
/
scripts
/
swingometer.as
< prev
Wrap
Text File
|
2005-01-18
|
6KB
|
198 lines
function Swingometer()
{
this.scorehandler = new LoadVars();
this.scorehandler._parent = this;
this.prizedrawhandler = new LoadVars();
this.prizedrawhandler._parent = this;
this.menscore = new Number();
this.womenscore = new Number();
this.menscore_txt.text = "";
this.womenscore_txt.text = "";
this.errormsg = new String();
if(_global.game.finalscore < 160)
{
this.entryform_mc.gotoAndStop("nodraw");
this.submit_btn._visible = false;
}
else
{
this.entryform_mc.gotoAndStop("draw");
this.submit_btn.onRelease = function()
{
this._alpha = 50;
this.enabled = false;
this._parent.checkAndSubmit();
};
}
this.zurich_btn.onRelease = function()
{
getURL("http://ad.uk.doubleclick.net/clk;10384938;10147104;x?http://www.zurichinsurance.co.uk/parking/?score=" + _global.game.finalscore,"_blank");
};
this.retry_btn.onRelease = function()
{
_global.game.reset();
};
this.entryform_mc.tickbox_mc.selected = false;
this.entryform_mc.tickbox_mc.onRelease = function()
{
if(!this.selected)
{
this.gotoAndStop("selected");
this.selected = true;
}
else
{
this.gotoAndStop("deselected");
this.selected = false;
}
};
this.showScore();
this.sendAndGetScores();
}
Swingometer.prototype = new MovieClip();
Swingometer.prototype.showScore = function()
{
this.score_txt.text = _global.game.finalscore + " points";
};
Swingometer.prototype.sendAndGetScores = function()
{
this.scorehandler.onLoad = function(success)
{
if(success)
{
if(this.successfulsave == "false")
{
this._parent.verbose_txt.htmlText = this.errormsg;
this._parent.debug_txt.text = this.referrer;
}
else
{
this._parent.menscore = this.men * 1;
this._parent.womenscore = this.women * 1;
this._parent.displayScores();
this._parent.calculateSwing();
}
}
};
this.scorehandler.score = _global.game.finalscore;
this.scorehandler.gender = _global.player_gender;
this.scorehandler.referrer = escape(_url);
this.scorehandler.sendAndLoad(_global.serverPath + _global.saveScoreScript,this.scorehandler,"POST");
};
Swingometer.prototype.displayScores = function()
{
this.gotoAndStop(2);
this.menscore_txt.text = this.menscore;
this.womenscore_txt.text = this.womenscore;
};
Swingometer.prototype.calculateSwing = function()
{
if(this.menscore == this.womenscore)
{
this.gotoAndStop(3);
}
else
{
if(this.menscore > this.womenscore)
{
var percentagemore = this.menscore / this.womenscore * 100 - 100;
if(percentagemore > 100)
{
percentagemore = 100;
}
percentagemore = Math.round(percentagemore);
var swing = percentagemore + 100;
}
else
{
var percentagemore = this.womenscore / this.menscore * 100 - 100;
if(percentagemore > 100)
{
percentagemore = 100;
}
percentagemore = Math.round(percentagemore);
var swing = percentagemore;
}
this.displaySwing(swing);
}
};
Swingometer.prototype.displaySwing = function(swing)
{
swing <= 100 ? this.gotoAndPlay(3) : this.gotoAndPlay(101);
this.onEnterFrame = function()
{
if(this._currentframe == swing)
{
this.stop();
delete this.onEnterFrame;
}
};
};
Swingometer.prototype.checkAndSubmit = function()
{
if(this.entryform_mc.name_txt.text != "" && this.entryform_mc.email_txt.text != "")
{
this.prizedrawhandler.name = this.entryform_mc.name_txt.text;
this.prizedrawhandler.email = this.entryform_mc.email_txt.text;
if(this.entryform_mc.tickbox_mc.selected)
{
this.prizedrawhandler.optin = "yes";
}
else
{
this.prizedrawhandler.optin = "no";
}
this.prizedrawhandler.referrer = escape(_url);
this.prizedrawhandler.onLoad = function(success)
{
if(success)
{
if(this.successfulsave == "false")
{
switch(this.errorcode * 1)
{
case 1:
this._parent.errormsg = "<center>Unauthorised referrer.</center>";
this._parent.gotoAndStop("dataerror");
break;
case 2:
this._parent.errormsg = "<center>That email address wasn\'t valid.<br>Please try again.</center>";
this._parent.entryform_mc.email_txt.text = "";
this._parent.gotoAndStop("dataerror");
}
this._parent.submit_btn._alpha = 100;
this._parent.submit_btn.enabled = true;
}
else
{
this._parent.gotoAndStop("success");
}
}
else
{
this._parent.errormsg = "<center>There was an error communicating with the server. Please email <a href=\'mailto:address@domain.com\'>address@domain.com</a> with details of this error.</center>";
this._parent.gotoAndStop("servererror");
}
};
this.prizedrawhandler.sendAndLoad(_global.serverPath + _global.prizeDrawScript,this.prizedrawhandler,"POST");
}
else
{
if(this.entryform_mc.name_txt.text == "")
{
this.errormsg = "Incomplete details...";
this.gotoAndStop("dataerror");
this.entryform_mc.name_txt.text = "Please enter your name!";
}
if(this.entryform_mc.email_txt.text == "")
{
this.errormsg = "Incomplete details...";
this.gotoAndStop("dataerror");
this.entryform_mc.email_txt.text = "Please enter your email address!";
}
this._parent.submit_btn._alpha = 100;
this._parent.submit_btn.enabled = true;
}
};
Object.registerClass("swingometer",Swingometer);